import Vue from 'vue'
import Router from 'vue-router'
import store from '../store/'
import layout from '../pages/common/layout.vue'

const routes =  [
    {
        path: '/', 
        component: layout,
        children: [{
            path: '/', 
            component: resolve => require(['../pages/index.vue'], resolve)
        },{
            path: '/movie', 
            component: resolve => require(['../pages/movie.vue'], resolve)
        },{
            path: '/demo', 
            component: resolve => require(['../components/hello.vue'], resolve)
        }]
    }
]

Vue.use(Router)

const router = new Router({
	routes
})

router.beforeEach((to, from, next) => {
    store.dispatch('loadingInit', true)
    next()
})

export default router